Skip to main content

Full text of "dg :: software :: utility :: 093-000009-00 Double Precision Absolute Value"

See other formats


DATA GENERAL 
CORPORATION 

Soufhboro, 

Massachusetts 01 772 

(617)485-9100 



PROGRAM 



Double Precision Absolute Value 



TAPES 



ASCII source: 090-000015 



ABSTi^ACT 



This routine computes the absolute value of a fixed point, 
double precision, two's complement number. 



Copyright (C) Data General Corp., 1969 093-000009-00 



-2- 

1. RECUIREBEBT S 

1. 1 Memory 

IK or larger memory 

1.2 Equipment 

BOVh central processor 

1. 3 External Subroutines 
Kone 

1.4 Other 
None 

2. OPERATING PROCEDURE 

2 . 1 Calling Sequence 

JSR .DABS 
return 

2.2 Input Format 

A fixed point, double precision, two's complement 
number in hC0 , AC1 - high order in hC0 , low order 
in AC1. The low order word is considered as an 
unsigned, 16-bit number. Bit of the high order 
word is considered the sign of the double precision 
number. A negative number, N, is represented ass 

2**32-abs(N) 

2.3 Output Format 

The absolute value of the input returned in hC0, 
AC1 - high order in AC$, low order in ACl. 

2.4 Error Returns 
None 

2.5 State of Active Registers upon Exit 

hC0, AC1, and Carry are destroyed. AC 2 and 

AC 3 remain mttcltang&a - 



-3- 



2 * 6 Cautions to User 

The absolute value of -2**31 cannot be 
represented and will be returned unchanged. 

3. DISCUSSION 

3.1 Algorithms 

The sign of the input is tested and, if negative, 
the input is negated. 

If we consider the number to be of the form 
2**16*A + B 

where A and B represent contents of hC0 , AC1, 

the negate 

= 2**32 - (2**16*A + B) 

= 2**16* (2**16-A) + 2**32-B 

2**32-B is merely a ISjEG of B, which will cause 
a borrow from the high order in every case but 
B=0. The borrow means we must form 

2**16-A-1 

for the high order, which is a COM of A. If 
B was 0, however, a NEG of A is required. 

3.2 Limitations and Accuracy 
The routine is exact. 

3.3 Size and Timing 

The routine is 6 instructions in length. 

For k>^0, execution time is 8.2 m seconds. 
For x<0, execution time is 19.4 ju seconds. 

3.4 References 

See section 2.2 of "How to use the NOVA" for a 
further discussion of double precision arithmetic. 



-4- 



3. 5 Flow Diagrams 
None 

4. EXAMPLES & APPLICATIONS 

An ASCII source tape (090-000015) of .DABS 
is provided with the KO¥A software, This tape 
should be edited into the user routine that requires 
double precision absolute value. 

5. PROGRAM LI ST IMG 

A listing of .DABS follows. No origin has been given, 
enabling the user to edit the routine anywhere into 
his program. 



1 - 4 ■- ' " '-** rWS COMPLEMENT My MB tit 

' I»>*PJf: M IN AC0# AC t-J;-- .,-»..- -,:, < = U 

5 A3S<N> IN ACtf* ACt 



1 -> ArJ.:iJL.i .. v^.X Of -a. 

CANiMOf ti£ «tPftE5i£#ft£iJ AMi 
UNCHANUEO 



15 He. 






00000 I 31 I 13 -OAa^J MOVL# 0,0,;>NC I fESf SIGN 

0000^! 001^00 j M p 0,j . pu5ifl\/i£ - KErUKN 

00000 124404 NfclU t,l,H£tx .J NfclGAft fO FOkM ABSOLUTE VALUE 

0^003 10000 1 curt 0,0, 0K0 

00004 133400 Nfaife 0,0 

00005 001400 JMP 11,3